library(tidyverse)
library(readxl)
path <- "Excel/800-899/896/896 Color Mixing.xlsx"
input <- read_excel(path, range = "A1:A20")
test <- read_excel(path, range = "B1:B20")
mix <- function(x, y) {
if (x == y) x else setdiff(c("r", "b", "y"), c(x, y))
}
result <- input %>%
mutate(
`Answer Expected` = map_chr(
`Color Codes`,
~ Reduce(mix, str_split(.x, "")[[1]])
)
) %>%
select(`Answer Expected`)
all_equal(result, test)
# [1] TRUEExcel BI - Excel Challenge 896
excel-challenges
excel-formulas
🔰 Find the Final color.

Challenge Description
🔰 Find the Final color.
Solutions
- Logic: Read the workbook ranges needed for the challenge; Derive the required intermediate columns; Parse the packed text or string structure.
- Strengths: The code maps the workbook rule into a compact, reproducible pipeline.
- Areas for Improvement: The solution assumes the workbook layout and selected ranges remain stable, so any structural change in the sheet would require small adjustments.
- Gem: The elegant part is how little code is needed once the correct intermediate representation is chosen.
import pandas as pd
path = "Excel/800-899/896/896 Color Mixing.xlsx"
input = pd.read_excel(path, usecols="A", nrows=20)
test = pd.read_excel(path, usecols="B", nrows=20)
def mix(x, y):
if x == y:
return x
else:
return list(set(['r', 'b', 'y']) - set([x, y]))[0]
def reduce_mix(code):
from functools import reduce
return reduce(mix, list(code))
input['Answer Expected'] = input['Color Codes'].apply(lambda x: reduce_mix(str(x)))
result = input[['Answer Expected']]
print(result.equals(test))The Python version mirrors the same workbook logic with a concise, direct implementation.
Difficulty Level
Easy / Medium
The business rule is clear, though the workbook still needs a few transformation steps to reach the expected output.